<?php
namespace Data;

use Data\Insert;
use Data\Update;

class Save extends \Data
{
    public static function Run($conf)
    {
        if (!is_array($conf)) {
            self::Error("插入参数必须为数组格式", __FILE__, __LINE__);
        }
        $data = self::$db->query("SELECT id FROM {$conf['table']} WHERE {$conf['where']}");
        if (!$data || $data->rowCount() == 0) {
            return Insert::Run($conf);
        } else {
            return Update::Run($conf);
        }
    }
}
